from flask import request
from flask_restful import Resource
from app.models import User
from app.extensions import db


class UserAPI(Resource):
    def get(self, uid):
        return {'UserAPI': '获取指定用户'}

    def put(self, uid):
        return {'UserAPI': '修改指定用户'}

    def delete(self, uid):
        return {'UserAPI': '删除指定用户'}


class UserListAPI(Resource):
    def get(self):
        return {'UserListAPI': '获取用户列表'}

    def post(self):
        openid = request.json['openid']
        session_key = request.json['session_key']
        user = User(openid=openid, session_key=session_key)
        db.session.add(user)
        return {'UserListAPI': '创建新的用户'}
